//
//  SignInViewController.m
//  ShoppingExperience
//
//  Created by LiYinDi on 15-1-4.
//  Copyright (c) 2015年 RuiBen. All rights reserved.
//

#import "MemberViewController.h"
#import <CoreLocation/CoreLocation.h>
#import "MemberListTableViewCell.h"
#import "GuideListTableViewCell.h"
#import "integralListTableViewCell.h"
#import "UIImageView+WebCache.h"

#import "HZAreaPickerView.h"
#import "EGORefreshTableHeaderView.h"
#import "TradeTableViewCell.h"
#import "FilterViewController.h"
#import "AddMemberViewController.h"

@interface MemberViewController ()<HZAreaPickerDelegate,EGORefreshTableHeaderDelegate,FilterViewControllerDelegate,FilterViewControllerDelegate,AddMemberDelegate>
{
    FilterViewController *filterVC;
    AddMemberViewController *addMemberVC;
    EGORefreshTableHeaderView *_refreshHeaderView;
    BOOL _reloading;
    
    NSUInteger _memberPageIndex;
    NSUInteger _memberTotalCount;
    NSUInteger _memberTotalPage;
    
    NSUInteger _tradePageIndex;
    NSUInteger _tradeTotalCount;
    NSUInteger _tradeTotalPage;
    
    NSUInteger _integralPageIndex;
    NSUInteger _integralTotalCount;
    NSUInteger _integralTotalPage;
    
   // NSMutableArray *mMembersArray;
    NSMutableArray *memberCodeArray;
    NSMutableArray *memberNameArray;
    NSMutableArray *memberPhoneArray;
    NSMutableArray *memberGuideArray;
    NSMutableArray *memberGuideCodeArray;
    NSMutableArray *memberGradeArray;
    NSMutableArray *memberStoreArray;
    NSMutableArray *memberAddressArray;
    NSMutableArray *memberIntegralArray;
    NSMutableArray *memberSexArray;
    NSMutableArray *memberTimeArray;
    
//    NSMutableArray *mFeaturesArray;
//    NSMutableArray *featureCodeArray;
//    NSMutableArray *featureNameArray;
    NSMutableArray *selectFeatureCodeArray;
    
   // NSMutableArray *mGuidesArray;
    NSMutableArray *guideNameArray;
    NSMutableArray *guideCodeArray;
   // NSMutableArray *mMemberDetailFeaturesArray;
    NSMutableArray *memberDetailFeaturesNameArray;
   
    NSMutableArray *integralIdArray;
    NSMutableArray *integralDateArray;
    NSMutableArray *integralReasonArray;
    NSMutableArray *integralAmountArray;
    NSMutableArray *integralPriceArray;
    NSMutableArray *integralIntegralArray;
    NSMutableArray *integralRIntegralArray;
    
    NSMutableArray *tradeDateArray;
    NSMutableArray *tradeStatusArray;
    NSMutableArray *tradeCodeArray;
    NSMutableArray *tradeDocTypeArray;
    NSMutableArray *tradeGuideNameArray;
    NSMutableArray *tradeStoreNameArray;
    NSMutableArray *tradeProductNameArray;
    NSMutableArray *tradePriceArray;
    NSMutableArray *tradeNumberArray;
    NSMutableArray *tradeWeightArray;
    
//    NSString *sexStr;
//    
//    NSString *provinceStr;
//    NSString *cityStr;
//    NSString *regionStr;
//    NSString *addressStr;
    
    NSString *guideCodeStr;
    NSString *memberCodeStr;
    
    BOOL isOpened;
    BOOL integralIsOpened;
    
    NSString *detailMemberNameStr;
   // NSString *detailPhoneStr;
    
 //   NSString *qrCodeStr;
   // NSString *addOrEditStr;
    NSString *userCodeStr;
    NSString *openIdStr;
    
    NSString *detailAreaStr;
    NSString *detailAddressStr;
    
    NSString *detailSexStr;
    
    
    UITextField *inputTextField;
    
    NSMutableArray *filterTypeCodeArray ;
    NSMutableArray *inputFilterCodeArray;
    NSMutableArray *inputMinResultFilterNameArray;
    NSMutableArray *inputMaxResultFilterNameArray;
    NSMutableArray *selectFilterCodeArray;
    NSMutableArray *selectFilterNameArray;
    NSMutableArray *selectCustomTimeArray ;
    NSMutableArray *customTimeFilterTypeCodeArray ;
    NSString *startTimeStr;
    NSString *endTimeStr;
    
    BOOL memberGradeIsOpen;
    NSMutableArray *memberGradeNameArray;
    NSMutableArray *memberGradeCodeArray;
    NSString *memberGradeCodeStr;

}
- (void)reloadTableViewDataSource;
- (void)doneLoadingTableViewData;
@property (strong, nonatomic) NSString *areaValue, *cityValue;
@property (strong, nonatomic) HZAreaPickerView *locatePicker;
@end

@implementation MemberViewController
@synthesize areaValue=_areaValue, cityValue=_cityValue;
@synthesize locatePicker=_locatePicker;
-(void)viewWillAppear:(BOOL)animated
{
    if (filterVC.view!=nil) {
        
        [filterVC removeFromParentViewController];
        [filterVC.view removeFromSuperview];
        
    }
    if (addMemberVC.view!=nil) {
        if (addMemberVC.timer!=nil) {
            [addMemberVC.timer invalidate];
            addMemberVC.timer=nil;
        }

        [addMemberVC removeFromParentViewController];
        [addMemberVC.view removeFromSuperview];
        
    }

   // mMembersArray=[NSMutableArray array];
    memberCodeArray=[NSMutableArray array];
    memberNameArray=[NSMutableArray array];
    memberPhoneArray=[NSMutableArray array];
    memberGuideArray=[NSMutableArray array];
    memberGradeArray=[NSMutableArray array];
    memberStoreArray=[NSMutableArray array];
    memberAddressArray=[NSMutableArray array];
    memberIntegralArray=[NSMutableArray array];
    memberGuideCodeArray=[NSMutableArray array];
    memberSexArray=[NSMutableArray array];
    memberTimeArray=[NSMutableArray array];
    _searchTextField.text=@"";
    
    [_addMemberButton addTarget:self action:@selector(addMemberBtnClick) forControlEvents:UIControlEventTouchUpInside];
   
    [self initMemberDetailView];
    [self initIntegralView];
    [self initTradeView];
    [self initOrderFilterView];
    _memberPageIndex=0;
    [self loadMemberNextPage:_memberPageIndex];
}
-(void)initOrderFilterView
{
    inputFilterCodeArray=[NSMutableArray array];
    inputMinResultFilterNameArray=[NSMutableArray array];
    inputMaxResultFilterNameArray=[NSMutableArray array];
    filterTypeCodeArray=[NSMutableArray array];
    customTimeFilterTypeCodeArray=[NSMutableArray array];
    selectFilterCodeArray=[NSMutableArray array];
    selectFilterNameArray=[NSMutableArray array];
    selectCustomTimeArray=[NSMutableArray array];
    
    startTimeStr=@"";
    endTimeStr=@"";
    
    [_orderFilterTitleLabel setTextColor:[UIColor colorWithRed:80.0f/255.0f green:80.0f/255.0f blue:80.0f/255.0f alpha:1.0f]];
    [_orderFilterImage setImage:[UIImage imageNamed:@"shaixuandingdan_.png"]];
    // [_orderFilterViewContainer bringSubviewToFront:_resetFilterBtn];
    
    _orderFilterBtn.layer.borderColor=[[UIColor colorWithRed:220.0f/255.0f green:220.0f/255.0f blue:220.0f/255.0f alpha:1] CGColor];
    _orderFilterBtn.layer.borderWidth= 1.0f;
    _orderFilterBtn.layer.cornerRadius=4;
    
    [_orderFilterBtn addTarget:self action:@selector(orderFilterBtnClick) forControlEvents:UIControlEventTouchUpInside];
    
}
-(void)orderFilterBtnClick
{
    if (filterVC.view!=nil) {
        
        [filterVC removeFromParentViewController];
        [filterVC.view removeFromSuperview];
        
    }
    filterVC=[[FilterViewController alloc] init];
    filterVC.delegate=self;
    filterVC.docTypeStr=@"Member";
    filterVC.selectCustomTimeArray=[NSMutableArray arrayWithArray:selectCustomTimeArray];
    filterVC.startTimeStr=startTimeStr;
    filterVC.endTimeStr=endTimeStr;
    // NSLog(@"selectFilterNameArray=22222======%@",selectFilterNameArray);
    filterVC.selectFilterNameArray=[NSMutableArray arrayWithArray:selectFilterNameArray];
    filterVC.view.frame = CGRectMake(0,
                                     0,
                                     self.view.bounds.size.width,
                                     self.view.bounds.size.height);
    
    [self addChildViewController:filterVC];
    [self.view addSubview:filterVC.view];
}
-(void)confirmFilterBtnClick:(NSMutableArray *)commonFilterTypeCodeArray commonSelectFilterCodeArray:(NSMutableArray *)commonSelectFilterCodeArray commonInputFilterCodeArray:(NSMutableArray *)commonInputFilterCodeArray commonInputMinResultFilterNameArray:(NSMutableArray *)commonInputMinResultFilterNameArray commonInputMaxResultFilterNameArray:(NSMutableArray *)commonInputMaxResultFilterNameArray commonCustomTimeFilterTypeCodeArray:(NSMutableArray *)commonCustomTimeFilterTypeCodeArray commonSelectCustomTimeArray:(NSMutableArray *)commonSelectCustomTimeArray commonSelectFilterNameArray:(NSMutableArray *)commonSelectFilterNameArray  commonStartTimeStr:(NSString *)commonStartTimeStr commonEndTimeStr:(NSString *)commonEndTimeStr isDefault:(NSString *)isDefault
{
    
    if ([isDefault isEqualToString:@"Y"]) {
        //  NSLog(@"_isDefault0000===%@",isDefault);
        [_orderFilterTitleLabel setTextColor:[UIColor colorWithRed:80.0f/255.0f green:80.0f/255.0f blue:80.0f/255.0f alpha:1.0f]];
        [_orderFilterImage setImage:[UIImage imageNamed:@"shaixuandingdan_.png"]];
    }
    else{
        // NSLog(@"_isDefault1111===%@",isDefault);
        [_orderFilterTitleLabel setTextColor:[UIColor colorWithRed:203.0f/255.0f green:164.0f/255.0f blue:67.0f/255.0f alpha:1.0f]];
        [_orderFilterImage setImage:[UIImage imageNamed:@"yishaixuan_.png"]];
    }
    
    filterTypeCodeArray=commonFilterTypeCodeArray;
    selectFilterCodeArray=commonSelectFilterCodeArray;
    inputFilterCodeArray=commonInputFilterCodeArray;
    inputMinResultFilterNameArray=commonInputMinResultFilterNameArray;
    inputMaxResultFilterNameArray=commonInputMaxResultFilterNameArray;
    customTimeFilterTypeCodeArray=commonCustomTimeFilterTypeCodeArray;
    selectCustomTimeArray=commonSelectCustomTimeArray;
    selectFilterNameArray=commonSelectFilterNameArray;
    
    startTimeStr=commonStartTimeStr;
    endTimeStr=commonEndTimeStr;
    
    [memberCodeArray removeAllObjects];
    [memberNameArray removeAllObjects];
    [memberAddressArray removeAllObjects];
    [memberPhoneArray removeAllObjects];
    [memberGuideArray removeAllObjects];
    [memberGuideCodeArray removeAllObjects];
    [memberGradeArray removeAllObjects];
    [memberTimeArray removeAllObjects];
    [memberIntegralArray removeAllObjects];
    [memberStoreArray removeAllObjects];
    [memberSexArray removeAllObjects];
    
    _memberPageIndex=0;
    [self loadMemberNextPage:_memberPageIndex];
    
}
-(void)initTradeView
{
//    CGRect viewFrame=_tradeViewContainer.frame;
//    viewFrame.origin.y=768;
//    _tradeViewContainer.frame=viewFrame;
    
    tradeDateArray=[NSMutableArray array];
    tradeStatusArray=[NSMutableArray array];
    tradeCodeArray=[NSMutableArray array];
    tradeDocTypeArray=[NSMutableArray array];
    tradeGuideNameArray=[NSMutableArray array];
    tradeStoreNameArray=[NSMutableArray array];
    tradeProductNameArray=[NSMutableArray array];
    tradePriceArray=[NSMutableArray array];
    tradeNumberArray=[NSMutableArray array];
    tradeWeightArray=[NSMutableArray array];
}
-(void)initIntegralView
{
    CGRect viewFrame=_integralViewContainer.frame;
    viewFrame.origin.y=768;
    _integralViewContainer.frame=viewFrame;
    
    
    [_integralAlphaView setBackgroundColor:[Global parseColor:WESTORE_TRANSCLUCENT]];
    [_integralAlphaView addTarget:self action:@selector(integralAlphaViewClick) forControlEvents:UIControlEventTouchUpInside];
}
-(void)initMemberDetailView
{
   detailMemberNameStr=@"";
  // detailPhoneStr=@"";
   detailAreaStr=@"";
   detailAddressStr=@"";
    detailSexStr=@"";
    
    [_memberDetailScrollView setContentOffset:CGPointMake(0, 0)];
  // mMemberDetailFeaturesArray=[NSMutableArray array];
   memberDetailFeaturesNameArray=[NSMutableArray array];
    

   integralIdArray=[NSMutableArray array];
    
   integralDateArray=[NSMutableArray array];
   integralReasonArray=[NSMutableArray array];
   integralAmountArray=[NSMutableArray array];
   integralPriceArray=[NSMutableArray array];
   integralIntegralArray=[NSMutableArray array];
    integralRIntegralArray=[NSMutableArray array];
    
    _integralButton.layer.borderColor=[[UIColor colorWithRed:220.0f/255.0f green:220.0f/255.0f blue:220.0f/255.0f alpha:1] CGColor];
    _integralButton.layer.borderWidth= 1.0f;
    _integralButton.layer.cornerRadius=3;
     [_integralButton addTarget:self action:@selector(integralBtnClick) forControlEvents:UIControlEventTouchUpInside];
    
    CGRect viewFrame=_memberDetailViewContainer.frame;
    viewFrame.origin.y=768;
    _memberDetailViewContainer.frame=viewFrame;
    [_memberDetailAlphaView setBackgroundColor:[Global parseColor:WESTORE_TRANSCLUCENT]];
     [_memberDetailAlphaView addTarget:self action:@selector(memberDetailAlphaViewClick) forControlEvents:UIControlEventTouchUpInside];
   
}
-(void)integralBtnClick
{
    [integralIdArray removeAllObjects];
    [integralReasonArray removeAllObjects];
    [integralDateArray removeAllObjects];
    [integralAmountArray removeAllObjects];
    [integralPriceArray removeAllObjects];
    [integralIntegralArray removeAllObjects];
    [integralRIntegralArray removeAllObjects];
    [UIView animateWithDuration:0.5 animations:^{
        
        CGRect viewFrame=_integralViewContainer.frame;
        viewFrame.origin.y=0;
        _integralViewContainer.frame=viewFrame;
        
    } completion:^(BOOL finished){
        
    }];

        _integralPageIndex=0;
        [self loadIntegralNextPage:_integralPageIndex];
        


   
}
-(void) loadIntegralNextPage:(NSUInteger)oldPageNum {
    if(oldPageNum!=0 && _integralTotalCount<=integralIdArray.count)
        return;
    if(oldPageNum == 0){
        [integralIdArray removeAllObjects];
        [_integralTableView reloadData];
    }
    _integralPageIndex=oldPageNum+1;
    [self requestIntegralList: _integralPageIndex pageSize:5];
}

-(void)requestIntegralList:(NSUInteger)pageIndex pageSize:(NSUInteger)pageSize
{
    if ([Global getLoginToken].length>0) {
        [Global showIndeterminateHudSub:@"加载中，请稍后。。。" delay:30 view:self.view];
        NSMutableDictionary *params=[[NSMutableDictionary alloc] init];
        [params setObject:[Global getLoginToken] forKey:@"Token"];
        NSNumber *pageSizeNumber = [NSNumber numberWithInteger:pageSize];
        NSNumber *pageIndexNumber = [NSNumber numberWithInteger:pageIndex];
        //        NSString *pageSizeStr=[NSString stringWithFormat:@"%d",pageSize];
        //        NSString *pageIndexStr=[NSString stringWithFormat:@"%d",pageIndex];
        
        [params setObject:pageSizeNumber forKey:@"PageSize"];
        [params setObject:pageIndexNumber forKey:@"PageIndex"];
         [params setObject:memberCodeStr forKey:@"UserCode"];
        
        
        [HttpRequest requestData:@"Guide/IntegralList" params:params success:^(BOOL isSuccess, SeverData *severDataDict) {
          //  NSLog(@"severDataDict22===%@",severDataDict.dataDict);
            if (isSuccess) {
                if ([[severDataDict.dataDict objectForKey:@"ResultInt"] integerValue]==0) {
                    [Global hideProgressHUDInternal:self.view];
                    
                    _integralTotalCount=[[severDataDict.dataDict objectForKey:@"TotalCount"] integerValue];
                  //  _detail_integralLabel.text=[NSString stringWithFormat:@"%d",_integralTotalCount];
                    if (_integralTotalCount%5!=0) {
                        _integralTotalPage=_integralTotalCount/5+1;
                    }
                    else if (_integralTotalCount%5==0)
                    {
                        _integralTotalPage=_integralTotalCount/5;
                    }
                    NSMutableArray *mIntegralDetailArray=[NSMutableArray arrayWithArray:[severDataDict.dataDict objectForKey:@"DataLine"]];
                    //  NSLog(@"mMembersArray===%@",mMembersArray);
                    if ( mIntegralDetailArray.count>0) {
                        for (int i=0; i< mIntegralDetailArray.count; i++) {
                            
                            [integralIdArray addObject:[[mIntegralDetailArray objectAtIndex:i] objectForKey:@"MYID"]];
                            [integralReasonArray addObject:[[mIntegralDetailArray objectAtIndex:i] objectForKey:@"Memo"]];
                            
                            [integralDateArray addObject:[[mIntegralDetailArray objectAtIndex:i] objectForKey:@"CreateDate"]];
                           // [integralAmountArray addObject:[[mIntegralDetailArray objectAtIndex:i] objectForKey:@"Integral"] ];
                            [integralPriceArray addObject:[[mIntegralDetailArray objectAtIndex:i] objectForKey:@"Amount"] ];
                            [integralIntegralArray addObject:[[mIntegralDetailArray objectAtIndex:i] objectForKey:@"Integral"]];
                            [integralRIntegralArray addObject:[[mIntegralDetailArray objectAtIndex:i] objectForKey:@"RIntegral"]];
                        }
                    }
                    
                    [_integralTableView reloadData];
                    
                    
                }
                else
                {
                    [Global hideProgressHUDInternal:self.view];
                    NSString *requestResultStr=[severDataDict.dataDict objectForKey:@"ResultString"];
                    //  [Global showTextHud:requestResultStr view:self.view];
                    [Global showTextHudSub:requestResultStr view:self.view];
                    
                    if ([[severDataDict.dataDict objectForKey:@"ResultInt"] integerValue]==9999) {
                        [Global loginViewController:self noteStr:requestResultStr];
                      //  [Global loginViewController:self];
                    }

                }
            }
            else
            {
                [Global hideProgressHUDInternal:self.view];
                [Global showTextHudSub:@"连接失败" view:self.view];
            }
        }];
        
    }
}

-(void)integralAlphaViewClick
{
    [UIView animateWithDuration:0.5 animations:^{
        
        CGRect viewFrame=_integralViewContainer.frame;
        viewFrame.origin.y=768;
        _integralViewContainer.frame=viewFrame;
        
    } completion:^(BOOL finished){
//        // if (mFeaturesArray.count==0) {
//        [self requestTags];
//        // }
        
    }];
 
}
-(void)addMemberBtnClick
{
       if (addMemberVC.view!=nil) {
        
        [addMemberVC removeFromParentViewController];
        [addMemberVC.view removeFromSuperview];
        
    }
    addMemberVC=[[AddMemberViewController alloc] init];
    addMemberVC.delegate=self;
    addMemberVC.addOrEditStr=@"A";
   addMemberVC.userCodeStr=@"";
    addMemberVC.docNumStr=@"";
    addMemberVC.view.frame = CGRectMake(0,
                                     0,
                                     self.view.bounds.size.width,
                                     self.view.bounds.size.height);
    
    [self addChildViewController:addMemberVC];
    [self.view addSubview:addMemberVC.view];
    
}
//addmemberDelegate
-(void)addOrEditMemberSuccess:(NSString *)memberCodeString memberGradeString:(NSString *)memberGradeString memberNameString:(NSString *)memberNameString memberPhoneString:(NSString *)memberPhoneString memberSexString:(NSString *)memberSexString memberIntegralString:(NSString *)memberIntegralString
{
    CGRect viewFrame=_memberDetailViewContainer.frame;
    viewFrame.origin.y=768;
    _memberDetailViewContainer.frame=viewFrame;
    
    [memberCodeArray removeAllObjects];
    [memberNameArray removeAllObjects];
    [memberAddressArray removeAllObjects];
    [memberPhoneArray removeAllObjects];
    [memberGuideArray removeAllObjects];
    [memberGradeArray removeAllObjects];
    [memberIntegralArray removeAllObjects];
    [memberStoreArray removeAllObjects];
    [memberSexArray removeAllObjects];
    [memberTimeArray removeAllObjects];
    [memberGuideCodeArray removeAllObjects];
    _memberPageIndex=0;
    [self loadMemberNextPage:_memberPageIndex];

}

-(void) loadMemberNextPage:(NSUInteger)oldPageNum {
    if(oldPageNum!=0 && _memberTotalCount<=memberCodeArray.count)
        return;
    if(oldPageNum == 0){
        [memberCodeArray removeAllObjects];
        [_memberListTableView reloadData];
    }
    _memberPageIndex=oldPageNum+1;
    [self requestMemberList: _memberPageIndex pageSize:7];
}
-(void)requestMemberList:(NSUInteger)pageIndex pageSize:(NSUInteger)pageSize
{
    if ([Global getLoginToken].length>0) {
        [Global showIndeterminateHudSub:@"加载中，请稍后。。。" delay:30 view:self.view];
        NSMutableDictionary *params=[[NSMutableDictionary alloc] init];
        [params setObject:[Global getLoginToken] forKey:@"Token"];
        NSNumber *pageSizeNumber = [NSNumber numberWithInteger:pageSize];
        NSNumber *pageIndexNumber = [NSNumber numberWithInteger:pageIndex];
        //        NSString *pageSizeStr=[NSString stringWithFormat:@"%d",pageSize];
        //        NSString *pageIndexStr=[NSString stringWithFormat:@"%d",pageIndex];
        
        [params setObject:pageSizeNumber forKey:@"PageSize"];
        [params setObject:pageIndexNumber forKey:@"PageIndex"];
        [params setObject:_searchTextField.text forKey:@"KeyWord"];
        NSMutableArray *mDocumentLine=[NSMutableArray array];
        for (int i=0; i<filterTypeCodeArray.count; i++) {
            
            NSMutableDictionary *dic = [NSMutableDictionary dictionary];
            //    NSLog(@"codeContentssss==%@",codeContent);
            [dic setValue:[filterTypeCodeArray objectAtIndex:i] forKey:@"FilterTypeCode"];
            //  NSLog(@"countContentssss==%@",countContent);
            [dic setValue:[selectFilterCodeArray objectAtIndex:i] forKey:@"FilterCode"];
            [mDocumentLine addObject:dic];
            
        }
        [params setObject:mDocumentLine forKey:@"DataLineFileterParam"];
        NSMutableArray *mDocumentLine1=[NSMutableArray array];
        for (int i=0; i<customTimeFilterTypeCodeArray.count; i++) {
            
            NSMutableDictionary *dic = [NSMutableDictionary dictionary];
            //    NSLog(@"codeContentssss==%@",codeContent);
            [dic setValue:[customTimeFilterTypeCodeArray objectAtIndex:i] forKey:@"FilterTypeCode"];
            //  NSLog(@"countContentssss==%@",countContent);
            [dic setValue:startTimeStr forKey:@"Value1"];
            [dic setValue:endTimeStr forKey:@"Value2"];
            [mDocumentLine1 addObject:dic];
            
        }
      [params setObject:mDocumentLine1 forKey:@"DataLineFileterParam2"];
        

       //NSLog(@"paramsLIST====%@",params);
        [HttpRequest requestData:@"Guide/MemberList" params:params success:^(BOOL isSuccess, SeverData *severDataDict) {
            if (isSuccess) {
                if ([[severDataDict.dataDict objectForKey:@"ResultInt"] integerValue]==0) {
                    [Global hideProgressHUDInternal:self.view];
                   // NSLog(@"tttt11====%@",severDataDict.dataDict);
                 
                    _memberTotalCount=[[severDataDict.dataDict objectForKey:@"TotalCount"] integerValue];
                    _totalMemberLabel.text=[NSString stringWithFormat:@"%lu",(unsigned long)_memberTotalCount];
                   // [self resizeLabel:_totalMemberLabel];
                      [Global resizeForLable:_totalMemberLabel WithText:_totalMemberLabel.text parentView:self.view];
                    CGRect frame=_totalMemberTagLabel.frame;
                    frame.origin.x=_totalMemberLabel.frame.origin.x+_totalMemberLabel.frame.size.width+3;
                    _totalMemberTagLabel.frame=frame;
                    if (_memberTotalCount%7!=0) {
                        _memberTotalPage=_memberTotalCount/7+1;
                    }
                    else if (_memberTotalCount%7==0)
                    {
                        _memberTotalPage=_memberTotalCount/7;
                    }
                   
                  NSMutableArray  *mMembersArray=[NSMutableArray arrayWithArray:[severDataDict.dataDict objectForKey:@"DataLine"]];
                    // NSLog(@"mMembersArray===%@",mMembersArray);
                    if ( mMembersArray.count>0) {
                        for (int i=0; i< mMembersArray.count; i++) {
                            
                            [memberCodeArray addObject:[[mMembersArray objectAtIndex:i] objectForKey:@"UserCode"]];
                            [memberNameArray addObject:[[mMembersArray objectAtIndex:i] objectForKey:@"UserName"]];
                            
                          //  NSString
                            [memberAddressArray addObject:[[mMembersArray objectAtIndex:i] objectForKey:@"Address"]];
                            [memberPhoneArray addObject:[[mMembersArray objectAtIndex:i] objectForKey:@"Phone"]];
                            [memberGuideArray addObject:[[mMembersArray objectAtIndex:i] objectForKey:@"GuideName"]];
                            [memberGuideCodeArray addObject:[[mMembersArray objectAtIndex:i] objectForKey:@"GuideCode"]];
                            [memberGradeArray addObject:[[mMembersArray objectAtIndex:i] objectForKey:@"Grade"]];
                            [memberIntegralArray addObject:[[mMembersArray objectAtIndex:i] objectForKey:@"Integral"]];
                            [memberStoreArray addObject:[[mMembersArray objectAtIndex:i] objectForKey:@"StoreName"]];
                            [memberSexArray addObject:[[mMembersArray objectAtIndex:i] objectForKey:@"Sex"]];
                            
                            [memberTimeArray addObject:[[mMembersArray objectAtIndex:i] objectForKey:@"CreateDate"]];
                        }
                    }
                   // NSLog(@"memberTimeArray===%@",memberTimeArray);
//                    for (int i=0; i<memberAddressArray.count; i++) {
//                        NSLog(@"memberAddressArray[%d]===%@",i,[memberAddressArray objectAtIndex:i]);
//                    }
                    
                    [_memberListTableView reloadData];
                    
                }
                else
                {
                    [Global hideProgressHUDInternal:self.view];
                    NSString *requestResultStr=[severDataDict.dataDict objectForKey:@"ResultString"];
                    //  [Global showTextHud:requestResultStr view:self.view];
                    [Global showTextHudSub:requestResultStr view:self.view];
                    
                    if ([[severDataDict.dataDict objectForKey:@"ResultInt"] integerValue]==9999) {
                      [Global loginViewController:self noteStr:requestResultStr];
                      //  [Global loginViewController:self];
                    }

                }
            }
            else
            {
                [Global hideProgressHUDInternal:self.view];
                [Global showTextHudSub:@"连接失败" view:self.view];
            }
        }];
        
    }
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    if (tableView==_memberListTableView) {
         return memberCodeArray.count;
    }
    else if (tableView==_tradeTableView)
    {
        return tradeCodeArray.count;
    }
   else
   {
       return integralIdArray.count;
   }
    
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
     if (tableView==_memberListTableView||tableView==_tradeTableView) {
    return 120;
     }
   
    else
        return 60;
    
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    if (tableView==_memberListTableView) {
        
  
        static NSString * const  MemberListIdentifier = @"MemberListCellIdentifier";
        MemberListTableViewCell *cell=( MemberListTableViewCell *)[tableView dequeueReusableCellWithIdentifier: MemberListIdentifier];
        if (cell==nil) {
            NSArray *array = [[NSBundle mainBundle] loadNibNamed:@"MemberListTableViewCell" owner:self options:nil];
            cell = [array objectAtIndex:0];
        }
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        if (memberSexArray.count>0) {
            if ([[memberSexArray objectAtIndex:indexPath.row] isEqualToString:@"男"]) {
                [cell.sexImageView setImage:[UIImage imageNamed:@"nan_.png"]];
            }
            else
                [cell.sexImageView setImage:[UIImage imageNamed:@"nv_.png"]];
        }
        if (memberGradeArray.count>0) {
            cell.gradeLabel.text=[memberGradeArray objectAtIndex:indexPath.row];
            [Global resizeForLable:cell.gradeLabel WithText:cell.gradeLabel.text parentView:self.view];

        }

        
        if (memberPhoneArray.count>0&&memberNameArray.count>0) {
            NSString *phoneStr=[memberPhoneArray objectAtIndex:indexPath.row];
            NSString *nameStr=[memberNameArray objectAtIndex:indexPath.row];
            NSString *str1=@"(";
            NSString *str2=@")";
            cell.nameAndPhoneLabel.text=[NSString stringWithFormat:@"%@%@%@%@",nameStr,str1,phoneStr,str2];
            [Global resizeForLable:cell.nameAndPhoneLabel WithText:cell.nameAndPhoneLabel.text parentView:self.view];
     
            CGRect frame=cell.sexImageView.frame;
            frame.origin.x=cell.nameAndPhoneLabel.frame.origin.x+cell.nameAndPhoneLabel.frame.size.width;
           cell.sexImageView.frame=frame;
            
            CGRect frame1=cell.gradeTagLabel.frame;
            frame1.origin.x=cell.sexImageView.frame.origin.x+cell.sexImageView.frame.size.width+10;
            cell.gradeTagLabel.frame=frame1;

            CGRect frame2=cell.gradeLabel.frame;
            frame2.origin.x=cell.gradeTagLabel.frame.origin.x+cell.gradeTagLabel.frame.size.width+2;
            cell.gradeLabel.frame=frame2;

            CGRect frame3=cell.integralTagLabel.frame;
            frame3.origin.x=cell.gradeLabel.frame.origin.x+cell.gradeLabel.frame.size.width+11;
            cell.integralTagLabel.frame=frame3;

            CGRect frame4=cell.integralLabel.frame;
            frame4.origin.x=cell.integralTagLabel.frame.origin.x+cell.integralTagLabel.frame.size.width+6;
            cell.integralLabel.frame=frame4;
        }
        if (memberGuideArray.count>0) {
            NSString *guideNameStr=[memberGuideArray objectAtIndex:indexPath.row];
            if (guideNameStr.length>0) {
                cell.guideNameLabel.text=guideNameStr;
            }
            else
            {
                cell.guideNameLabel.text=@"未填写";
            }
            [Global resizeForLable:cell.guideNameLabel WithText:cell.guideNameLabel.text parentView:self.view];

            CGRect frame=cell.storeNameTagLabel.frame;
            frame.origin.x=cell.guideNameLabel.frame.origin.x+cell.guideNameLabel.frame.size.width+15;
            cell.storeNameTagLabel.frame=frame;
            
            CGRect frame1=cell.storeNameLabel.frame;
            frame1.origin.x=cell.storeNameTagLabel.frame.origin.x+cell.storeNameTagLabel.frame.size.width+2;
            cell.storeNameLabel.frame=frame1;
            
        }

       if (memberStoreArray.count>0) {
        cell.storeNameLabel.text=[memberStoreArray objectAtIndex:indexPath.row];
           // NSLog(@"cell.storeNameLabel.text=====%@",cell.storeNameLabel.text);
        [Global resizeForLable:cell.storeNameLabel WithText:cell.storeNameLabel.text parentView:self.view];

       }
       if (memberAddressArray.count>0) {
           NSString *addressStr1=[memberAddressArray objectAtIndex:indexPath.row];
           if (addressStr1.length>0) {
               cell.addressLabel.text=addressStr1;
           }
       else
       {
           cell.addressLabel.text=@"未填写";
       }
          
       }
        
        if (memberTimeArray.count>0) {
            cell.timeLabel.text=[memberTimeArray objectAtIndex:indexPath.row];
            CGRect frame=cell.timeTagLabel.frame;
            frame.origin.x=cell.storeNameLabel.frame.origin.x+cell.storeNameLabel.frame.size.width+15;
            cell.timeTagLabel.frame=frame;
            
            CGRect frame1=cell.timeLabel.frame;
            frame1.origin.x=cell.timeTagLabel.frame.origin.x+cell.timeTagLabel.frame.size.width+2;
            cell.timeLabel.frame=frame1;
        }
    if (memberIntegralArray.count>0) {
        cell.integralLabel.text=[NSString stringWithFormat:@"%ld",(long)[[memberIntegralArray objectAtIndex:indexPath.row] integerValue]];
    }
        if (indexPath.row == [memberCodeArray count] - 1)
        {
            if (_memberPageIndex<=_memberTotalPage) {
                //  NSLog(@"###LOADING???");
                [self loadMemberNextPage:_memberPageIndex];
            }
        }
        return cell;
    }
    else if (tableView==_tradeTableView)
    {
        static NSString * const  tradeIdentifier = @"tradeIdentifier";
        TradeTableViewCell *cell=( TradeTableViewCell *)[tableView dequeueReusableCellWithIdentifier: tradeIdentifier];
        if (cell==nil) {
            NSArray *array = [[NSBundle mainBundle] loadNibNamed:@"TradeTableViewCell" owner:self options:nil];
            cell = [array objectAtIndex:0];
        }
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
//        cell.selectedBackgroundView = [[UIView alloc] initWithFrame:cell.frame] ;
//        cell.selectedBackgroundView.backgroundColor = [UIColor colorWithRed:250.0f/255.0f green:250.0f/255.0f blue:250.0f/255.0f alpha:1.0f];
        if (tradeCodeArray.count>0) {
            cell.codeLabel.text=[tradeCodeArray objectAtIndex:indexPath.row];
          //  [self resizeLabel: cell.codeLabel];
             [Global resizeForLable:cell.codeLabel WithText:cell.codeLabel.text parentView:_memberDetailScrollView];
        }
        if (tradeDocTypeArray.count>0) {
            cell.docTypeLabel.text=[tradeDocTypeArray objectAtIndex:indexPath.row];
            [Global resizeForLable:cell.docTypeLabel WithText:cell.docTypeLabel.text parentView:_memberDetailScrollView];
           // [self resizeLabel:cell.docTypeLabel];
            
            if([[tradeDocTypeArray objectAtIndex:indexPath.row] isEqualToString:@"定金"])
            {
                [cell.docTypeLabel setBackgroundColor:[UIColor colorWithRed:200/255.0 green:156/255.0 blue:43.0/255.0 alpha:1.0f]];
            }
           else if([[tradeDocTypeArray objectAtIndex:indexPath.row] isEqualToString:@"退货"])
           {
               [cell.docTypeLabel setBackgroundColor:[UIColor colorWithRed:192/255.0 green:0 blue:5.0/255.0 alpha:1.0f]];
           }
           
            else if([[tradeDocTypeArray objectAtIndex:indexPath.row] isEqualToString:@"服务"])
            {
                 [cell.docTypeLabel setBackgroundColor:[UIColor colorWithRed:85.0f/255.0f green:138.0f/255.0f blue:5.0/255.0 alpha:1.0f]];
            }
            else
            {
                [cell.docTypeLabel setBackgroundColor:[UIColor blackColor]];
            }

            CGRect frame=cell.productNameLabel.frame;
            frame.origin.x=cell.docTypeLabel.frame.origin.x+cell.docTypeLabel.frame.size.width+3;
            cell.productNameLabel.frame=frame;

        }
        if (tradeStatusArray.count>0) {
            NSString *statusStr=[tradeStatusArray objectAtIndex:indexPath.row];
            cell.statusLabel.text=[NSString stringWithFormat:@"【%@】",[tradeStatusArray objectAtIndex:indexPath.row]];
            CGRect frame=cell.statusLabel.frame;
            frame.origin.x=cell.codeLabel.frame.origin.x+cell.codeLabel.frame.size.width;
            cell.statusLabel.frame=frame;
            if ([statusStr isEqualToString:@"已收定金"])
            {
                //  [cell.statusLabel setTextColor:[UIColor colorWithRed:252.0f/255.0f green:114.0f/255.0f blue:84.0f/255.0f alpha:1.0f]];
                
                [cell.statusLabel setTextColor:[Global parseStatusColor:statusStr]];
                
            }

            
            else
            {
                [cell.statusLabel setTextColor:[Global parseStatusColor:statusStr]];
                
            }

            
        }
        NSString *guideStr=@"";
         NSString *dateStr1=@"";
        NSString *storeNameStr=@"";
        if (tradeGuideNameArray.count>0) {
            guideStr =[tradeGuideNameArray objectAtIndex:indexPath.row];


        }
        if (tradeStoreNameArray.count>0) {
            storeNameStr=[tradeStoreNameArray objectAtIndex:indexPath.row];
        }
        if (tradeDateArray.count>0) {
            dateStr1=[tradeDateArray objectAtIndex:indexPath.row];
        }
        cell.detailLabel.text=[NSString stringWithFormat:@"导购 %@   门店 %@   日期 %@",guideStr,storeNameStr,dateStr1];
        if (tradePriceArray.count>0) {
            
            float priceFloat=[[tradePriceArray objectAtIndex:indexPath.row] floatValue];
            cell.priceLabel.text=[NSString stringWithFormat:@"¥%@",[Global floatConvertPercentile:priceFloat]];
        }
        NSString *numberStr=@"";
        NSString *weightStr=@"";
        NSString *nameStr=@"";
        if (tradeNumberArray.count>0) {
            numberStr=[NSString stringWithFormat:@"%ld",(long)[[tradeNumberArray objectAtIndex:indexPath.row] integerValue]];
        }
        if (tradeWeightArray.count>0) {
            weightStr=[NSString stringWithFormat:@"%0.02f",[[tradeWeightArray objectAtIndex:indexPath.row] floatValue]];
        }
        
        if (tradeProductNameArray.count>0 ) {
            nameStr=[tradeProductNameArray objectAtIndex:indexPath.row];
            if ([numberStr floatValue]>1) {
                cell.productNameLabel.text=[NSString stringWithFormat:@"%@...  共%@件/%@g",nameStr,numberStr,weightStr];
            }
            else
            {
                cell.productNameLabel.text=[NSString stringWithFormat:@"%@  共%@件/%@g",nameStr,numberStr,weightStr];
            }
            [Global resizeForLable:cell.productNameLabel WithText:cell.productNameLabel.text parentView:_memberDetailScrollView];

            CGRect frame=cell.priceTagLabel.frame;
            frame.origin.x=cell.productNameLabel.frame.origin.x+cell.productNameLabel.frame.size.width+15;
            cell.priceTagLabel.frame=frame;
            
            CGRect frame1=cell.priceLabel.frame;
            frame1.origin.x=cell.priceTagLabel.frame.origin.x+cell.priceTagLabel.frame.size.width+3;
            cell.priceLabel.frame=frame1;
        }
        if (indexPath.row == [tradeCodeArray count] - 1)
        {
                if (_tradePageIndex<=_tradeTotalPage) {
                //  NSLog(@"###LOADING???");
                [self loadTradeNextPage:_tradePageIndex];
            }
        }

        return cell;

    }
    else
    {
        static NSString * const  IntegralListIdentifier = @"IntegralListIdentifier";
        integralListTableViewCell *cell=( integralListTableViewCell *)[tableView dequeueReusableCellWithIdentifier: IntegralListIdentifier];
        if (cell==nil) {
            NSArray *array = [[NSBundle mainBundle] loadNibNamed:@"integralListTableViewCell" owner:self options:nil];
            cell = [array objectAtIndex:0];
        }
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        NSString *integralDateStr=@"";
        NSString *integralResonStr=@"";
        NSString *integralPriceStr=@"";
        if (integralDateArray.count>0) {
            integralDateStr=[integralDateArray objectAtIndex:indexPath.row];
           
        }
        if (integralReasonArray.count>0) {
            integralResonStr=[integralReasonArray objectAtIndex:indexPath.row];
           // NSLog(@"integralResonStr====%@",integralResonStr);
            }
        if (integralPriceArray.count>0) {
            integralPriceStr=[NSString stringWithFormat:@"¥%ld",(long)[[integralPriceArray objectAtIndex:indexPath.row] integerValue]];
        }
        cell.dateLabel.text=[NSString stringWithFormat:@"%@  %@  %@",integralDateStr,integralResonStr,integralPriceStr];

        NSString *integralStr=@"";
        NSString *rIntegralStr=@"";
        if (integralIntegralArray.count>0) {
            if([[integralIntegralArray objectAtIndex:indexPath.row] integerValue]>0)
            integralStr=[NSString stringWithFormat:@"+%ld",(long)[[integralIntegralArray objectAtIndex:indexPath.row] integerValue]];
            else
             integralStr=[NSString stringWithFormat:@"%ld",(long)[[integralIntegralArray objectAtIndex:indexPath.row] integerValue]];
            }
        if (integralRIntegralArray.count>0) {
//            if ([[integralRIntegralArray objectAtIndex:indexPath.row] integerValue]>0) {
//                 rIntegralStr=[NSString stringWithFormat:@"+%d",[[integralRIntegralArray objectAtIndex:indexPath.row] integerValue]];
//            }
//            else
//            {
                 rIntegralStr=[NSString stringWithFormat:@"%ld",(long)[[integralRIntegralArray objectAtIndex:indexPath.row] integerValue]];
          //  }
           
        }
        cell.integralContentLabel.text=[NSString stringWithFormat:@"结银%@   抵扣-%@",integralStr,rIntegralStr];
//        if (integralAmountArray.count>0) {
//            cell.integralAmountLabel.text=[NSString stringWithFormat:@"%ld",(long)[[integralAmountArray objectAtIndex:indexPath.row] integerValue]];
//        }
       
        NSInteger resultInt=[integralStr integerValue]-[rIntegralStr integerValue];
        NSString *resultStr;
        
        if (resultInt>=0) {
            resultStr=[NSString stringWithFormat:@"+%ld",(long)resultInt];
        }
        else  {
            resultStr=[NSString stringWithFormat:@"%ld",(long)resultInt];
        }

            cell.integralAmountLabel.text=[NSString stringWithFormat:@"%@",resultStr];
       

        if (indexPath.row == [integralIdArray count] - 1)
        {
            if (_integralPageIndex<=_integralTotalPage) {
                //  NSLog(@"###LOADING???");
                [self loadIntegralNextPage:_integralPageIndex];
            }
        }

        return cell;
    }
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
     if (tableView==_memberListTableView)
    {
        [memberDetailFeaturesNameArray removeAllObjects];
         [selectFeatureCodeArray removeAllObjects];
        for (UILabel *label in _detail_tagView.subviews) {
            [label removeFromSuperview];
            
        }
        guideCodeStr=[memberGuideCodeArray objectAtIndex:indexPath.row];
        userCodeStr=[memberCodeArray objectAtIndex:indexPath.row];
        [self requestMemberDetail:[memberCodeArray objectAtIndex:indexPath.row]];
        memberCodeStr=[memberCodeArray objectAtIndex:indexPath.row];
              [UIView animateWithDuration:0.5 animations:^{
            
            CGRect viewFrame=_memberDetailViewContainer.frame;
            viewFrame.origin.y=0;
            _memberDetailViewContainer.frame=viewFrame;
            
        } completion:^(BOOL finished){
        }];
        
        [tradeCodeArray removeAllObjects];
        [tradeDocTypeArray removeAllObjects];
        [tradeDateArray removeAllObjects];
        
        //  NSString
        [tradeGuideNameArray removeAllObjects];
        [tradeStoreNameArray removeAllObjects];
        [tradeProductNameArray removeAllObjects];
        [tradePriceArray removeAllObjects];
        [tradeStatusArray removeAllObjects];
        [tradeNumberArray removeAllObjects];
        [tradeWeightArray removeAllObjects];
        _tradePageIndex=0;
        [self loadTradeNextPage:_tradePageIndex];

    }
}
-(void) loadTradeNextPage:(NSUInteger)oldPageNum {
    if(oldPageNum!=0 && _tradeTotalCount<=tradeCodeArray.count)
        return;
    if(oldPageNum == 0){
        [tradeCodeArray removeAllObjects];
        [_tradeTableView reloadData];
    }
    _tradePageIndex=oldPageNum+1;
    [self requestTradeList: _tradePageIndex pageSize:50];
}
-(void)requestTradeList:(NSUInteger)pageIndex pageSize:(NSUInteger)pageSize
{
    if ([Global getLoginToken].length>0) {
        [Global showIndeterminateHudSub:@"加载中，请稍后。。。" delay:30 view:self.view];
        NSMutableDictionary *params=[[NSMutableDictionary alloc] init];
        [params setObject:[Global getLoginToken] forKey:@"Token"];
        NSNumber *pageSizeNumber = [NSNumber numberWithInteger:pageSize];
        NSNumber *pageIndexNumber = [NSNumber numberWithInteger:pageIndex];
        //        NSString *pageSizeStr=[NSString stringWithFormat:@"%d",pageSize];
        //        NSString *pageIndexStr=[NSString stringWithFormat:@"%d",pageIndex];
        
        [params setObject:userCodeStr forKey:@"MemberCode"];
        [params setObject:pageSizeNumber forKey:@"PageSize"];
        [params setObject:pageIndexNumber forKey:@"PageIndex"];
       // [params setObject:_searchTextField.text forKey:@"KeyWord"];
        //   NSLog(@"paramsLIST====%@",params);
        [HttpRequest requestData:@"Guide/MemberTransactionDetail" params:params success:^(BOOL isSuccess, SeverData *severDataDict) {
            if (isSuccess) {
                if ([[severDataDict.dataDict objectForKey:@"ResultInt"] integerValue]==0) {
                    [Global hideProgressHUDInternal:self.view];
                  //   NSLog(@"tttt11====%@",severDataDict.dataDict);
                    _tradeTotalCount=[[severDataDict.dataDict objectForKey:@"TotalCount"] integerValue];
                  
                    if (_tradeTotalCount%50!=0) {
                        _tradeTotalPage=_tradeTotalCount/50+1;
                    }
                    else if (_tradeTotalCount%50==0)
                    {
                        _tradeTotalPage=_tradeTotalCount/50;
                    }
                    
                    float priceFloat=[[severDataDict.dataDict objectForKey:@"MemberTotal"] floatValue];
                    _tradePriceLabel.text=[NSString stringWithFormat:@"%@",[Global floatConvertPercentile:priceFloat]];
                   // [self resizeLabel:_tradePriceLabel];
                     [Global resizeForLable:_tradePriceLabel WithText:_tradePriceLabel.text parentView:_memberDetailScrollView];
                    
                    CGRect tradeFrame=_tradePriceLabel.frame;
                    tradeFrame.origin.x=592-_tradePriceLabel.frame.size.width;
                    _tradePriceLabel.frame=tradeFrame;
                    
                    CGRect tradeFrame1=_tradePriceTagLabel.frame;
                    tradeFrame1.origin.x=592-_tradePriceLabel.frame.size.width-83;
                    _tradePriceTagLabel.frame=tradeFrame1;
                    
                  NSMutableArray * mTradesArray=[NSMutableArray arrayWithArray:[severDataDict.dataDict objectForKey:@"DataLine"] ];
                    // NSLog(@"mMembersArray===%@",mMembersArray);
                   // if ( mMembersArray.count>0) {
                        for (int i=0; i< mTradesArray.count; i++) {
                            
                            [tradeCodeArray addObject:[[mTradesArray objectAtIndex:i] objectForKey:@"DocNum"]];
                            [tradeDateArray addObject:[[mTradesArray objectAtIndex:i] objectForKey:@"DocDate"]];
                            [tradeDocTypeArray addObject:[[mTradesArray objectAtIndex:i] objectForKey:@"DocType"] ];
                            //  NSString
                            [tradeGuideNameArray addObject:[[mTradesArray objectAtIndex:i] objectForKey:@"GuideName"]];
                            [tradeStoreNameArray addObject:[[mTradesArray objectAtIndex:i] objectForKey:@"StoreName"]];
                            [tradeProductNameArray addObject:[[mTradesArray objectAtIndex:i] objectForKey:@"ItemName"]];
                            [tradePriceArray addObject:[[mTradesArray objectAtIndex:i] objectForKey:@"DocTotal"]];
                            [tradeStatusArray addObject:[[mTradesArray objectAtIndex:i] objectForKey:@"DocStatus"]];
                            [tradeNumberArray addObject:[[mTradesArray objectAtIndex:i] objectForKey:@"Number"]];
                            [tradeWeightArray addObject:[[mTradesArray objectAtIndex:i] objectForKey:@"GramTotal"]];
                            
                        }
                    
                    [_tradeTableView reloadData];
                    
                    CGRect viewFrame3=_tradeTableView.frame;
                   
                    viewFrame3.size.height=120*tradeCodeArray.count;
                    
                    _tradeTableView.frame=viewFrame3;
                    
                    [_memberDetailScrollView setContentSize:CGSizeMake(0, _tradeTableView.frame.origin.y+ _tradeTableView.frame.size.height+10)];
                    [_memberDetailScrollView setScrollEnabled:YES];

                    
                }
                else
                {
                    [Global hideProgressHUDInternal:self.view];
                    NSString *requestResultStr=[severDataDict.dataDict objectForKey:@"ResultString"];
                    //  [Global showTextHud:requestResultStr view:self.view];
                    [Global showTextHudSub:requestResultStr view:self.view];
                    
                    
                    if ([[severDataDict.dataDict objectForKey:@"ResultInt"] integerValue]==9999) {
                    [Global loginViewController:self noteStr:requestResultStr];
                       // [Global loginViewController:self];
                    }

                }
            }
            else
            {
                [Global hideProgressHUDInternal:self.view];
                [Global showTextHudSub:@"连接失败" view:self.view];
            }
        }];
        
    }
}

-(IBAction)memberEditBtnClick:(id)sender
{
    
    if (addMemberVC.view!=nil) {
        
        [addMemberVC removeFromParentViewController];
        [addMemberVC.view removeFromSuperview];
        
    }
    addMemberVC=[[AddMemberViewController alloc] init];
    addMemberVC.delegate=self;
    addMemberVC.addOrEditStr=@"U";
    addMemberVC.userCodeStr=memberCodeStr;
    addMemberVC.docNumStr=@"";
    addMemberVC.view.frame = CGRectMake(0,
                                        0,
                                        self.view.bounds.size.width,
                                        self.view.bounds.size.height);
    
    [self addChildViewController:addMemberVC];
    [self.view addSubview:addMemberVC.view];

}
-(void)memberDetailAlphaViewClick
{
    [_memberDetailScrollView setContentOffset:CGPointMake(0, 0)];
    [UIView animateWithDuration:0.5 animations:^{
        
        CGRect viewFrame=_memberDetailViewContainer.frame;
        viewFrame.origin.y=768;
        _memberDetailViewContainer.frame=viewFrame;
        
    } completion:^(BOOL finished){
    }];
    
    _integralDetailViewContainer.hidden=YES;
    UIImage *closeImage=[UIImage imageNamed:@"jiantou_down.png"];
    [_integeralListArrow setImage:closeImage];
    CGRect frame=_integralDetailViewContainer.frame;
    
    frame.size.height=1;
    [_integralDetailViewContainer setFrame:frame];

}
//-(IBAction)memberDetailBackClick:(id)sender
//{
//    
//    
//}
-(void)requestMemberDetail:(NSString *)userCode
{
    if ([Global getLoginToken].length>0) {
        [Global showIndeterminateHudSub:@"加载中，请稍后。。。" delay:30 view:self.view];
        NSMutableDictionary *params=[[NSMutableDictionary alloc] init];
        [params setObject:[Global getLoginToken] forKey:@"Token"];
        [params setObject:userCode forKey:@"UserCode"];
        [HttpRequest requestData:@"Guide/FindMemberInf" params:params success:^(BOOL isSuccess, SeverData *severDataDict) {
         //  NSLog(@"serrr==%@",severDataDict.dataDict);
            if (isSuccess) {
                if ([[severDataDict.dataDict objectForKey:@"ResultInt"] integerValue]==0) {
                    [Global hideProgressHUDInternal:self.view];
                   // NSLog(@"345==%@",severDataDict.dataDict );
                    detailSexStr=[severDataDict.dataDict  objectForKey:@"Sex"];
                    if ([detailSexStr isEqualToString:@"男"]) {
                        [_detail_sexImage setImage:[UIImage imageNamed:@"nan_.png"]];
                    }
                    else if ([detailSexStr isEqualToString:@"女"])
                        [_detail_sexImage setImage:[UIImage imageNamed:@"nv_.png"]];
                    _detail_nameAndPhoneLabel.text=[NSString stringWithFormat:@"%@(%@)",[severDataDict.dataDict objectForKey:@"UserName"],[severDataDict.dataDict objectForKey:@"Phone"]];
                    _detail_gradeLabel.text=[severDataDict.dataDict objectForKey:@"Grade"];
                   // [self resizeLabel:_detail_gradeLabel];
                     [Global resizeForLable:_detail_gradeLabel WithText:_detail_gradeLabel.text parentView:_memberDetailScrollView];
                  //   NSLog(@"_detail_nameAndPhoneLabel.text==%@",_detail_nameAndPhoneLabel.text);
                   // [self resizeLabel:_detail_nameAndPhoneLabel];
                    _detail_nameAndPhoneLabel.numberOfLines = 0;
                    _detail_nameAndPhoneLabel.lineBreakMode = NSLineBreakByWordWrapping;
                    CGSize maximumLabelSize = CGSizeMake(1000, _detail_nameAndPhoneLabel.frame.size.height);
                    
                    CGSize expectSize = [_detail_nameAndPhoneLabel sizeThatFits:maximumLabelSize];
                    CGRect frame11 = CGRectMake(_detail_nameAndPhoneLabel.frame.origin.x, _detail_nameAndPhoneLabel.frame.origin.y,expectSize.width, _detail_nameAndPhoneLabel.frame.size.height );
                    _detail_nameAndPhoneLabel.frame=frame11;

                    
                    CGRect frame=_detail_sexImage.frame;
                    frame.origin.x=_detail_nameAndPhoneLabel.frame.origin.x+_detail_nameAndPhoneLabel.frame.size.width;
                    _detail_sexImage.frame=frame;
                    
                    CGRect frame1=_detail_gradeTagLabel.frame;
                    frame1.origin.x=_detail_sexImage.frame.origin.x+_detail_sexImage.frame.size.width+10;
                    _detail_gradeTagLabel.frame=frame1;
                    
                    CGRect frame2=_detail_gradeLabel.frame;
                    frame2.origin.x=_detail_gradeTagLabel.frame.origin.x+_detail_gradeTagLabel.frame.size.width+2;
                    _detail_gradeLabel.frame=frame2;
                    
                    CGRect frame3=_detail_integralTagLabel.frame;
                    frame3.origin.x=_detail_gradeLabel.frame.origin.x+_detail_gradeLabel.frame.size.width+16;
                    _detail_integralTagLabel.frame=frame3;
                    
                    CGRect frame4=_detail_integralLabel.frame;
                    frame4.origin.x=_detail_integralTagLabel.frame.origin.x+_detail_integralTagLabel.frame.size.width+3;
                    _detail_integralLabel.frame=frame4;

//                    provinceStr =[severDataDict.dataDict objectForKey:@"ProvinceName"];
//                    cityStr=[severDataDict.dataDict objectForKey:@"CityName"];
//                    regionStr=[severDataDict.dataDict objectForKey:@"RegionName"] ;
                    detailAreaStr=[NSString stringWithFormat:@"%@%@%@",[severDataDict.dataDict objectForKey:@"ProvinceName"],[severDataDict.dataDict objectForKey:@"CityName"],[severDataDict.dataDict objectForKey:@"RegionName"]];
                    detailAddressStr=[severDataDict.dataDict objectForKey:@"Address"];
                    detailMemberNameStr=[severDataDict.dataDict objectForKey:@"UserName"];
                  //  detailPhoneStr=[severDataDict.dataDict objectForKey:@"Phone"];
                    
                    _detail_integralLabel.text=[NSString stringWithFormat:@"%d",[[severDataDict.dataDict objectForKey:@"Integral"] integerValue]];
                    _currentIntegralLabel.text=[NSString stringWithFormat:@"%d",[[severDataDict.dataDict objectForKey:@"Integral"] integerValue]];
                    _detail_remarkView.text=[severDataDict.dataDict objectForKey:@"Memo"];
                    //[Global resizeTextView:_detail_remarkView contentStr: _detail_remarkView.text];
                    CGFloat height=  [Global heightForTextView:_detail_remarkView WithText:_detail_remarkView.text];
                    
                    CGRect frameA=_detail_remarkView.frame;
                    frameA.size.height=height;
                    _detail_remarkView.frame=frameA;
                    CGRect frameD=_detail_LastSubView.frame;
                    frameD.origin.y=_detail_remarkView.frame.origin.y+_detail_remarkView.frame.size.height+2;
                    _detail_LastSubView.frame=frameD;
                    
                    
                    CGRect frameE=_detail_LastView.frame;
                    frameE.size.height=_detail_LastSubView.frame.origin.y+_detail_LastSubView.frame.size.height+2;
                    _detail_LastView.frame=frameE;
                    
                    _detail_guideNameLabel.text=[severDataDict.dataDict objectForKey:@"GuideName"];
                    
                    [Global resizeForLable:_detail_guideNameLabel WithText:_detail_guideNameLabel.text parentView:_memberDetailScrollView];
                   // [self resizeLabel:_detail_guideNameLabel];
                    CGRect frame5=_detail_storeNameTagLabel.frame;
                    frame5.origin.x=_detail_guideNameLabel.frame.origin.x+_detail_guideNameLabel.frame.size.width+10;
                    _detail_storeNameTagLabel.frame=frame5;
                    
                    CGRect frame6=_detail_storeNameLabel.frame;
                    frame6.origin.x=_detail_storeNameTagLabel.frame.origin.x+_detail_storeNameTagLabel.frame.size.width+3;
                    _detail_storeNameLabel.frame=frame6;
                    NSString *birthStr=[severDataDict.dataDict objectForKey:@"BirthDate"];
                    if (birthStr.length>0) {
                         _detail_birthLabel.text=birthStr;
                    }
                    else
                    {
                        _detail_birthLabel.text=@"";
                    }
                    //[self resizeLabel:_detail_birthLabel];
                     [Global resizeForLable:_detail_birthLabel WithText:_detail_birthLabel.text parentView:_memberDetailScrollView];
                   
                    _detail_storeNameLabel.text=[severDataDict.dataDict objectForKey:@"StoreName"];
                   // [self resizeLabel:_detail_storeNameLabel];
                     [Global resizeForLable:_detail_storeNameLabel WithText:_detail_storeNameLabel.text parentView:_memberDetailScrollView];
                    
                    NSString *nickStr=[severDataDict.dataDict objectForKey:@"NickName"];
                    if (nickStr.length>0) {
                        _detail_wechatIDLabel.text=nickStr;
                    }
                    else
                    {
                        _detail_wechatIDLabel.text=@"无";
                    }
                    CGRect wFrame=_detail_wechatIDtTagLabel.frame;
                     wFrame.origin.x=_detail_birthLabel.frame.origin.x+_detail_birthLabel.frame.size.width+12;
                    _detail_wechatIDtTagLabel.frame=wFrame;
                    
                    CGRect tFrame=_detail_wechatIDLabel.frame;
                    tFrame.origin.x=_detail_wechatIDtTagLabel.frame.origin.x+_detail_wechatIDtTagLabel.frame.size.width+3;
                    _detail_wechatIDLabel.frame=tFrame;

                    if ([severDataDict.dataDict objectForKey:@"CreateDate"] != [NSNull null]) {
                         _detail_timeLabel.text=[severDataDict.dataDict objectForKey:@"CreateDate"];
                    }
                    CGRect timeTagFrame=_detail_timeTagLabel.frame;
                    timeTagFrame.origin.x=_detail_storeNameLabel.frame.origin.x+_detail_storeNameLabel.frame.size.width+12;
                    _detail_timeTagLabel.frame=timeTagFrame;
                    
                    CGRect timeFrame=_detail_timeLabel.frame;
                    timeFrame.origin.x=_detail_timeTagLabel.frame.origin.x+_detail_timeTagLabel.frame.size.width+2;
                    _detail_timeLabel.frame=timeFrame;
                    
                    _detail_addressLabel.text=[NSString stringWithFormat:@"%@%@%@%@",[severDataDict.dataDict objectForKey:@"ProvinceName"],[severDataDict.dataDict objectForKey:@"CityName"],[severDataDict.dataDict objectForKey:@"RegionName"],[severDataDict.dataDict objectForKey:@"Address"]];//[severDataDict.dataDict objectForKey:@"Address"];
                  //  _detail_storeNameLabel.text=[]
                    
                  //  [memberDetailFeaturesNameArray removeAllObjects];
                   
                   NSMutableArray * mMemberDetailFeaturesArray=[NSMutableArray arrayWithArray:[severDataDict.dataDict objectForKey:@"DataLine"]];
                    [memberDetailFeaturesNameArray removeAllObjects];
                    //[memberDetailFeaturesNameArray removeAllObjects];
                    for (int i=0; i<mMemberDetailFeaturesArray.count; i++) {
                        [memberDetailFeaturesNameArray addObject:[[mMemberDetailFeaturesArray objectAtIndex:i] objectForKey:@"FeatureName"]];
                        [selectFeatureCodeArray addObject:[[mMemberDetailFeaturesArray objectAtIndex:i] objectForKey:@"FeatureCode"]];
                    }
                    for (UILabel *label in _detail_tagView.subviews) {
                        [label removeFromSuperview];
                        
                    }

                    [self setMemberDetailTagView];
                 //   _detail_storeNameLabel.text

                }
                else
                {
                    [Global hideProgressHUDInternal:self.view];
                    NSString *requestResultStr=[severDataDict.dataDict objectForKey:@"ResultString"];
                    //  [Global showTextHud:requestResultStr view:self.view];
                    [Global showTextHudSub:requestResultStr view:self.view];
                    
//                    if (timer!=nil) {
//                        [timer invalidate];
//                        timer=nil;
//                    }
//                    UIViewController *controller=[[GlobalViewController alloc]init];
//                    [self.navigationController pushViewController:controller animated:YES];
                    if ([[severDataDict.dataDict objectForKey:@"ResultInt"] integerValue]==9999) {
                       
                        [Global loginViewController:self noteStr:requestResultStr];
                      //  [Global loginViewController:self];
                    }

                }
            }
            else
            {
                [Global hideProgressHUDInternal:self.view];
                [Global showTextHudSub:@"连接失败" view:self.view];
            }
        }];
        
    }

}
-(void)setMemberDetailTagView
{
     [_detail_tagView setTags:memberDetailFeaturesNameArray];
//    for (int i=0; i<memberDetailFeaturesNameArray.count; i++) {
////        NSLog(@"m%d==%@",i ,[memberDetailFeaturesNameArray objectAtIndex:i]);
//        UILabel *label=[[UILabel alloc] initWithFrame:CGRectMake(0, 0, 70, 18)];
//        [label setText:[memberDetailFeaturesNameArray objectAtIndex:i]];
//       // [self resizeLabel:label];
//        label.textAlignment=NSTextAlignmentCenter;
//        CGRect rect=label.frame;
//         rect.size.height=18;
//        rect.size.width=label.frame.size.width;
//        rect.origin.x=rect.size.width*(i%6)+15;
//        rect.origin.y=8+25*(i/6);
//        label.frame=rect;
//        label.tag=i;
//     //   NSLog(@"ffffffffW===%f",label.frame.size.width);
//       //  NSLog(@"fffffffX===%f",label.frame.origin.x);
//        
//        
//        [label setTextColor:[UIColor colorWithRed:209.0f/255.0f green:174.0f/255.0f blue:80.0f/255.0f alpha:1.0f] ];
//        
//            //  [button setBackgroundColor:[UIColor colorWithRed:254.0f/255.0f green:249.0f/255.0f blue:228.0f/255.0f alpha:1.0f]];
////        button.layer.borderWidth=1;
////         button.layer.borderColor=[[UIColor colorWithRed:226.0f/255.0f green:208.0f/255.0f blue:166.0f/255.0f alpha:1.0f] CGColor];
////        button.layer.cornerRadius=16;
////        button.titleLabel.font = [UIFont systemFontOfSize: 15.0];
////        [button setTitle:[memberDetailFeaturesNameArray objectAtIndex:i] forState:UIControlStateNormal];
////        [button setTitleColor:[UIColor colorWithRed:209.0f/255.0f green:174.0f/255.0f blue:80.0f/255.0f alpha:1.0f] forState:UIControlStateNormal];
////       
//        //[button addTarget:self action:@selector(tagButtonClick:) forControlEvents:UIControlEventTouchUpInside];
//        [_detail_tagView addSubview:label];
//    }
//    if (memberDetailFeaturesNameArray.count>6) {
//        CGRect viewFrame=_detail_tagView.frame;
//        viewFrame.size.height=108;
//        _detail_tagView.frame=viewFrame;
//    }
//    else if(memberDetailFeaturesNameArray.count<6&&memberDetailFeaturesNameArray.count>0)
//    {
//        CGRect viewFrame=_detail_tagView.frame;
//        viewFrame.size.height=49;
//        _detail_tagView.frame=viewFrame;
//    }
//   if(memberDetailFeaturesNameArray.count==0)
//    {
//        CGRect viewFrame=_detail_tagView.frame;
//        viewFrame.size.height=0;
//        _detail_tagView.frame=viewFrame;
//    }
//
    
    CGRect viewFrame2=_memberDetailTitleView.frame;
    viewFrame2.size.height=_detail_tagView.frame.origin.y+_detail_tagView.frame.size.height;
    _memberDetailTitleView.frame=viewFrame2;
    
    CGRect viewFrame1=_detail_LastView.frame;
    viewFrame1.origin.y=_memberDetailTitleView.frame.origin.y+_memberDetailTitleView.frame.size.height+3;
    _detail_LastView.frame=viewFrame1;
    
    CGRect viewFrame3=_tradeTableView.frame;
    viewFrame3.origin.y=_detail_LastView.frame.origin.y+_detail_LastView.frame.size.height+10;
     //viewFrame3.size.height=120*tradeCodeArray.count;
    //viewFrame3.size.height=768-viewFrame3.origin.y;
    _tradeTableView.frame=viewFrame3;
    
   // NSLog(@"tradeCodeArray===%@",tradeCodeArray);
    
//    CGRect viewFrame4=_tradeTableView.frame;
//    viewFrame4.size.height=viewFrame3.size.height;
//    _tradeTableView.frame=viewFrame4;
   
    
    [_memberDetailScrollView setContentSize:CGSizeMake(0, _tradeTableView.frame.origin.y+ _tradeTableView.frame.size.height+10)];
    [_memberDetailScrollView setScrollEnabled:YES];

}

- (BOOL)textFieldShouldReturn:(UITextField *)textField
{
    if (textField==_searchTextField) {
        [memberCodeArray removeAllObjects];
        [memberNameArray removeAllObjects];
        [memberAddressArray removeAllObjects];
        [memberPhoneArray removeAllObjects];
        [memberGuideArray removeAllObjects];
        [memberGuideCodeArray removeAllObjects];
        [memberGradeArray removeAllObjects];
         [memberTimeArray removeAllObjects];
        [memberIntegralArray removeAllObjects];
        [memberStoreArray removeAllObjects];
        [memberSexArray removeAllObjects];
        _memberPageIndex=0;
        [self loadMemberNextPage:_memberPageIndex];
        [_searchTextField resignFirstResponder];
    }
    
    return YES;

}
- (void)viewDidLoad {
    [super viewDidLoad];
    if (_refreshHeaderView == nil) {
        EGORefreshTableHeaderView *view = [[EGORefreshTableHeaderView alloc] initWithFrame:CGRectMake(0.0f, 0.0f - _memberListTableView.bounds.size.height, self.view.frame.size.width, _memberListTableView.bounds.size.height)];
        view.delegate = self;
        [_memberListTableView addSubview:view];
        _refreshHeaderView = view;
        
        
    }
    
    //  update the last update date
    [_refreshHeaderView refreshLastUpdatedDate];
   
}
#pragma mark -
#pragma mark Data Source Loading / Reloading Methods

- (void)reloadTableViewDataSource{
    [memberCodeArray removeAllObjects];
    [memberNameArray removeAllObjects];
    [memberAddressArray removeAllObjects];
    [memberPhoneArray removeAllObjects];
    [memberGuideArray removeAllObjects];
    [memberGuideCodeArray removeAllObjects];
    [memberGradeArray removeAllObjects];
     [memberTimeArray removeAllObjects];
    [memberIntegralArray removeAllObjects];
    [memberStoreArray removeAllObjects];
    [memberSexArray removeAllObjects];

    _memberPageIndex=0;
    [self loadMemberNextPage:_memberPageIndex];
    //  should be calling your tableviews data source model to reload
    //  put here just for demo
    _reloading = YES;
    
}

- (void)doneLoadingTableViewData{
    
    //  model should call this when its done loading
    _reloading = NO;
    [_refreshHeaderView egoRefreshScrollViewDataSourceDidFinishedLoading:_memberListTableView];
    
}


#pragma mark -
#pragma mark UIScrollViewDelegate Methods

- (void)scrollViewDidScroll:(UIScrollView *)scrollView{
     if (scrollView==_memberListTableView) {
    [_refreshHeaderView egoRefreshScrollViewDidScroll:scrollView];
     }
}

- (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate{
    if (scrollView==_memberListTableView) {
    [_refreshHeaderView egoRefreshScrollViewDidEndDragging:scrollView];
    }
}


#pragma mark -
#pragma mark EGORefreshTableHeaderDelegate Methods

- (void)egoRefreshTableHeaderDidTriggerRefresh:(EGORefreshTableHeaderView*)view{
    
    [self reloadTableViewDataSource];
    [self performSelector:@selector(doneLoadingTableViewData) withObject:nil afterDelay:3.0];
    
}

- (BOOL)egoRefreshTableHeaderDataSourceIsLoading:(EGORefreshTableHeaderView*)view{
    
    return _reloading; // should return if data source model is reloading
    
}

- (NSDate*)egoRefreshTableHeaderDataSourceLastUpdated:(EGORefreshTableHeaderView*)view{
    
    return [NSDate date]; // should return date data source was last changed
    
}


- (BOOL)validateMobile:(NSString *)mobileNum
{
    /**
     * 手机号码
     * 移动：134[0-8],135,136,137,138,139,150,151,157,158,159,182,187,188
     * 联通：130,131,132,152,155,156,185,186
     * 电信：133,1349,153,180,189
     */
    NSString * MOBILE = @"^1(3[0-9]|5[0-35-9]|7[678]|8[025-9])\\d{8}$";
    /**
     10         * 中国移动：China Mobile
     11         * 134[0-8],135,136,137,138,139,150,151,157,158,159,182,187,188
     12         */
    NSString * CM = @"^1(34[0-8]|(3[5-9]|5[017-9]|8[278])\\d)\\d{7}$";
    /**
     15         * 中国联通：China Unicom
     16         * 130,131,132,152,155,156,185,186
     17         */
    NSString * CU = @"^1(3[0-2]|5[256]|8[56])\\d{8}$";
    /**
     20         * 中国电信：China Telecom
     21         * 133,1349,153,180,189
     22         */
    NSString * CT = @"^1((33|53|8[09])[0-9]|349)\\d{7}$";
    
    NSString *others=@"^1((4[57]|7[0]))\\d{8}$";
    /**
     25         * 大陆地区固话及小灵通
     26         * 区号：010,020,021,022,023,024,025,027,028,029
     27         * 号码：七位或八位
     28         */
    // NSString * PHS = @"^0(10|2[0-5789]|\\d{3})\\d{7,8}$";
    
    NSPredicate *regextestmobile = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", MOBILE];
    NSPredicate *regextestcm = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", CM];
    NSPredicate *regextestcu = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", CU];
    NSPredicate *regextestct = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", CT];
     NSPredicate *regextestothers = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", others];
    
    if (([regextestmobile evaluateWithObject:mobileNum] == YES)
        || ([regextestcm evaluateWithObject:mobileNum] == YES)
        || ([regextestct evaluateWithObject:mobileNum] == YES)
        || ([regextestcu evaluateWithObject:mobileNum] == YES)||([regextestothers evaluateWithObject:mobileNum] == YES))
    {
        return YES;
    }
    else
    {
        return NO;
    }
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
@end
